package cn.com.xinjinfu.pdoulcProduct.manager;

import android.app.Activity;
import android.content.Context;

import java.util.ArrayList;
import java.util.List;

import cn.com.xinjinfu.pdoulcProduct.BaseApplication;

/**
 * Created by Administrator on 2016/1/17 0017.
 */
public class ActivityManager {

    public List<Activity> activitys = new ArrayList<>();
    private static ActivityManager mInstance;
    private Context context;

    private ActivityManager() {
        context = BaseApplication.getInstance().getApplicationContext();
    }

    public synchronized static ActivityManager getInstance() {
        if (null == mInstance) {
            mInstance = new ActivityManager();
        }
        return mInstance;
    }

    // add Activity
    public void addActivity(Activity activity) {
        activitys.add(activity);
    }

    public void removeActivity(Activity activity) {
        activitys.remove(activity);
    }

    public void exitActivity() {
        for (Activity activity : activitys) {
            if (activity != null)
                activity.finish();
        }
    }

}
